<?php
namespace Admin\Model;
use Think\Model\RelationModel;
class SchoolModel extends RelationModel {
    
    protected $_validate = array(
        array('sname','require','学校名必须且唯一！',0,'unique',1),
        array('ranking','number','综合排名必须为数字！'),
        array('city','require','城市必须！'),
        array('category','number','学校类型必须为数字！'),
        array('rank','number','学校级别必须为数字！'),
        array('nature','number','办学性质必须为数字！'),
        array('graduate','number','读研比例必须为数字！'),
        array('abroad','number','出国比例必须为数字！'),
        array('manbili','number','男生比例必须为数字！'),
        array('weburl','url','网址错误！'),
        array('salary','number','薪资超过必须为数字！'),
    );
    
    protected $_link = array(
        'schoolArea' => array(
            'mapping_type'      => self::HAS_ONE,
            'mapping_key'       => 'city',
            'mapping_fields'    => 'dataname',
            'foreign_key'       => 'datavalue',
            'class_name'        => 'Cascadedata',
            'condition'         => 'datagroup = "schoolArea"',
            'as_fields'         => 'dataname:cityname'
        ),
        
    );
}

/* namespace Admin\Model;
use Think\Model;
class SchoolModel extends Model{
    protected $_validate = array(
        array('sname','require','学校名必须且唯一！',0,'unique',1),
        array('ranking','number','综合排名必须为数字！'),
        array('city','require','城市必须！'),
        array('category','number','学校类型必须为数字！'),
        array('rank','number','学校级别必须为数字！'),
        array('nature','number','办学性质必须为数字！'),
        array('graduate','number','读研比例必须为数字！'),
        array('abroad','number','出国比例必须为数字！'),
        array('manbili','number','男生比例必须为数字！'),
        array('weburl','url','网址错误！'),
        array('salary','number','薪资超过必须为数字！'),
    );
    
} */

